package com.suyin.ximoon.plugin.mybatis;

import java.util.List;

/**
 * sql 筛选条件 where的参数模型
 * 
 * @author guo
 * 
 */
public class WhereCondition extends Column   {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2993142188649385473L;

 	/*private String columnName;
	
	private Object columnValue; */
	/**
	 * sql的比较运算符
	 * 
	 * @author guo
	 * 
	 */
	public enum WhereRestrict {
		EQ("="), GT(">"), GE(">="), NE("<>"), LT("<"), LE("<="), LIKE("like"), IN("in"), BETWEEN(" between  "), NOTIN(" not in "), IS("  is "), ISNOT(
				" is not ");

		private String name;

		private WhereRestrict(String name) {
			this.name = name;
		}

		public String getName() {
			return this.name;
		}

		public void setName(String name) {
			this.name = name;
		}

	}

	public String getColumnName() {
		return columnName;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public Object getColumnValue() {
		return columnValue;
	}

	public void setColumnValue(Object columnValue) {
		this.columnValue = columnValue;
	}

	/**
	 * between的第二个值
	 */
	private Object otherValue;

	/**
	 * 运算符
	 */
	private WhereRestrict res = WhereRestrict.EQ;

	public Object getOtherValue() {
		return otherValue;
	}

	public WhereRestrict getRes() {
		return res;
	}

	public void setRes(WhereRestrict res) {
		this.res = res;
	}

	public void setOtherValue(Object otherValue) {
		this.otherValue = otherValue;
	}

	WhereCondition() {

	}

	public  WhereCondition(String columnName, WhereRestrict res, Object value) {
		this.columnName = columnName;
		this.res = res;
		this.columnValue = value;
	}

	/**
	 * 介于2个字段之间
	 * 
	 * @param paramName
	 *            字段名
	 * @param res
	 *            between
	 * @param low
	 *            小值
	 * @param hig
	 *            大值
	 */
	public WhereCondition(String columnName, Object low, Object hig) {
		this.columnName = columnName;
		this.res = WhereRestrict.BETWEEN;
		this.columnValue = low;
		this.otherValue = hig;
	}

	/**
	 * in 或者 not in
	 * 
	 * @param paramName
	 * @param res
	 * @param value
	 * 这里不用泛型，因为定义泛型的时候 Object 不好传递
	 */
	public WhereCondition(String columnName, WhereRestrict res, List value) {
		this.columnName = columnName;
		this.res = res;
		this.columnValue = value;
	}

	/**
	 * in 或者 not in
	 * 
	 * @param paramName
	 * @param res
	 * @param value
	 */
	public WhereCondition(String columnName, WhereRestrict res, Object[] value) {
		this.columnName = columnName;
		this.res = res;
		this.columnValue = value;
	}


}
